package com.negocio.entidades;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="Matricula")
@IdClass(value=MatriculaPK.class)
public class Matricula implements Serializable{
	@Id
	@ManyToOne
	@JoinColumn(nullable=false)
	private Usuario aluno;
	
	@Id
	@ManyToOne
	@JoinColumn(nullable=false)
	private CompCurr cc;
	
	@Temporal(TemporalType.DATE)
	@Column(nullable=false)
	private Date dtMat;
	
	@Enumerated(EnumType.STRING)
	@Column(nullable=false)
	private SituacaoMatricula situacao;

	public Usuario getAluno() {
		return aluno;
	}

	public void setAluno(Usuario aluno) {
		this.aluno = aluno;
	}

	public CompCurr getCc() {
		return cc;
	}

	public void setCc(CompCurr cc) {
		this.cc = cc;
	}

	public Date getDtMat() {
		return dtMat;
	}

	public void setDtMat(Date dtMat) {
		this.dtMat = dtMat;
	}

	public SituacaoMatricula getSituacao() {
		return situacao;
	}

	public void setSituacao(SituacaoMatricula situacao) {
		this.situacao = situacao;
	}
	

	@Override
	public boolean equals(Object m){
		if(m instanceof Matricula){
			final Matricula mat = (Matricula) m;
			if(!(mat.getAluno().getId() == this.aluno.getId() && mat.getCc().getId() == this.cc.getId() && mat.getDtMat().equals(this.dtMat))){
				return false;
			}
			return true;
		}
		return false;
	}
	
	
	@Override
	public int hashCode(){
		return this.hashCode();
	}
}
